//
//  SocketRocketUtility.h
//  SUN
//
//  Created by 孙俊 on 17/2/16.
//  Copyright © 2017年 SUN. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <SocketRocket.h>


@protocol SocketRocketUtilityDelegate <NSObject>

@optional
// scoket连接成功
//- (void) connectSocketScucess;
//
////scoket连接失败
//- (void) connectSocketFail;
//
// scoketToken认证成功
- (void) socketTokenReciveScucess:(NSString *)scucessMessage;

// 连接频道成功
- (void) socketConnectChannelScucess:(NSString *)scucessMessage;

// scoket接收消息
- (void) socketReciveMessage:(NSString *)recevedMessage;

// scoket接收历史消息
- (void) scoketReciveHistoryMessage:(NSString *)recevedMessage;

// scoket发送消息
- (void) scoketPostMessage:(NSString *)postMessage;

//发送提示信息
- (void) scoketTipsMessage:(NSString *)tips;

//socket解析失败
-(void) socketAnalysisMessageFail:(NSString *)failMessage;


@end

@interface SocketRocketUtility : NSObject

/** 获取连接状态 */
@property (nonatomic,assign,readonly) SRReadyState socketReadyState;
@property (nonatomic,weak) id<SocketRocketUtilityDelegate> delegate;

/** 开始连接 */
-(void)SRWebSocketOpenWithURLString:(NSString *)urlString
                              token:(NSString *)token
                           channels:(NSArray *)channels;

/** 关闭连接 */
- (void)SRWebSocketClose;

/** 发送数据 */
- (void)sendData:(id)data;

+ (SocketRocketUtility *)instance;

@end
